local nya__shenxian = fk.CreateSkill {

  name = "nya__shenxian",

  tags = {  },

}



nya__shenxian:addEffect(fk.AfterCardsMove, {
  name = "nya__shenxian",
  anim_type = "drawcard",
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(nya__shenxian.name) and player:usedSkillTimes(nya__shenxian.name, Player.HistoryTurn) == 0 then
      for _, move in ipairs(data) do
        if move.extra_data and move.extra_data.nya__shenxian then
          return true
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, nya__shenxian.name)
  end,
})
nya__shenxian:addEffect(fk.BeforeCardsMove, {
  refresh_events = {fk.BeforeCardsMove},
  can_refresh = function(self, event, target, player, data)
    if player:hasSkill(nya__shenxian.name) and player:usedSkillTimes(nya__shenxian.name, Player.HistoryTurn) == 0 then
      for _, move in ipairs(data) do
        if move.from ~= player.id and move.moveReason == fk.ReasonDiscard then
          return true
        end
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    for _, move in ipairs(data) do
      if move.from ~= player.id and move.moveReason == fk.ReasonDiscard then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerHand then
            local card = Fk:getCardById(info.cardId)
            if card.type == Card.TypeBasic or (not player:hasSkill("nya__play", true) and card.type ~= Card.TypeEquip) then
              move.extra_data = move.extra_data or {}
              move.extra_data.nya__shenxian = true
              return
            end
          end
        end
      end
    end
  end,
})

return nya__shenxian